package demo7;

class OutClass {
    private int n1 = 10;
    public int n2 = 20;
    public static int n3 = 30;

    public void menth() {
        System.out.println("menth被执行了");
    }
    public static void func() {
        System.out.println("func被执行了");
    }

    //静态内部类
    static class InnerClass {
        private int n4 = 4;
        public int n5 = 5;
        public static int n6 = 6;
        public static int n3 = 3;
        OutClass outClass = new OutClass();//可以使在静态内部类中访问外部类的非静态成员
        public void test() {
            System.out.println("test被执行了");
            //在静态内部类中，不能直接访问外部类中的非静态成员
            System.out.println(outClass.n1);
            System.out.println(outClass.n2);
            //当静态内部类和外部类的静态成员名一样时。优先访问静态内部类当中的成员
            System.out.println(n3);
            System.out.println(n4);
            System.out.println(n5);
            System.out.println(n6);
        }


    }
}
public class Test {
    public static void main(String[] args) {
        OutClass.InnerClass innerClass =
                new OutClass.InnerClass();
        innerClass.test();
    }
}
